Hello and welcome to feed you.
We are going to be adding the javascript functionality that will make the come to tool work inside me
hastier mail.
I've already got a reference to the external javascript.
I've called it hitch converter Duchess.
I'm not going to go ahead and at the farm so I click on file and then you can I'm going to save this
file and save it has inside the same directory and I'm going to call it here.
Convert to dot g s.
I'll save that.
And that will become my javascript file kisses on the bottom right says javascript.
I've already pre staged the javascript code.
Um just cannot add that in and gone through the code line by line.
So this is my javascript so on line run.
I've got a document called get elemen by the method and I am passing into that parameter.
The submit inputs of go into the hastier month here we've got an idea code submit.
That is the I.D. I'm passing into this and then I am attaching the ADD event list now to that.
Okay so this is busy this add event list.
Basically is used to attach an event handler to the document.
So I've now attached an event handler to the document and also attached click event.
See this is the click event.
So when someone clicks on this submit button it would trigger this function here.
Cord high it converts to this function called Hide.
Converter is the function I have defined here on line 3 so anything between the opening curly braces
and the ending calibrators is a function that will execute when someone clicks on the submit button.
So the click is event.
The add in bit list now is the event had handler that will listen out for the Click event so the moment
it listens out and hit.
Here's a click to call this function here which is a function.
I'm defining here saw line 3.
I started the definition of the function.
You define a function by typing the word function followed by the name you want to call the function
and then you atash.
Apparently this is opening and closing parentheses.
You also have to have typed openly and quickly braces inside the Culebra it is where you had the logic
for code for functions so anything you want a function to do has to be between the curly braces.
You can also pass in arguments inside parenthesis if you want to perform on our parent.
This is an empty line full I have defined a variable called feet and set that to your cause or parse
it passed into basically is a function that passes its drink and returns an integer.
Okay that's what the parsing than inside the parentheses for this parse it.
I have the document get elemen by iteam method and am in Ft.
Which you can get here from this is a mail import So whatever import is entered there is what I am referring
to here.
And you know it is a matter attaching a value so whatever input is entered the value of that we going
to multiply that by 12.
One inch is equivalent to.
If you want to find the value of an inch you multiply the value in Ft.
Time.
12.
So whatever value you entering as ft.
You have to monts imply that by off to give you the value of an inch.
So for example if I had a value of six as my feet I would need to moduli that by 12 to convert that
in two inches.
And then here a variable called inches.
Again I'm using the parse into function and I'm using to document or get element a D passing in the
inches I did.
Which you can get from here inside this input.
So passing in that again I am grabbing what ever a value is entered into that input here on line 7.
I have got a variable called centimetres and upsetting that to equal so the value of the FT variable
plus inches multiply by 2.5 for 1 inch.
Valennes to 2.5 for senti meters.
Okay.
So all you need is in parenthesis is that we have to do this couple on first with the parenthetic it
will do the multiplication first because his higher up in order than the plot so right now writing this
imperent this is a means to do this first.
So it will add whatever value quote for my feet it will then add that to the inches and then multiply
that by 2.5 for line 8.
I've got a variable called N and upsetting that to a devalue of the centimetre variable and then in
the attaching that to this to fixed metal.
This to fix is a method that converts in number into his drink and you can also keep a specified number
of decimals.
In this case have you just passed saying the value of zero.
Is going to keep the zero decimal places so if you want to have two decimal places you have to pass
in that value of two.
Inside that parenthesis.
So we are converting feet into inches by multiply and by 12.
Here and there and we are converting the value here.
We're converting to get the value a centimetre.
We add undervaluing feet plus inches is variable feet plus inches.
Our models apply in there by 2.5 4 because an inch is equivalent of 2.5 4 centimetres.
Here is the still fixed method which converts in number into his drink can have past 10.
The value of several decimal places.
Line 12.
This is where will be hard put to results so we grab a middle document or get to eliminate part D and
D D where grabbing is a results idea which is this idea here to grab in that we are replacing the content
with the inner email and with setting that to the value of.
Which is this value here.
So whether VAT is variable output is going to display that inside this result div.
So that's it.
I am going to save that and then we can test to see everything work.
I'm going to open up the directory and double click on the hatim of file.
Okay so this is our hide.
Convert.
I'm just going to type in around on it and see if 5 feet so 5 feet 10 inches.
Convert that into a centimetre.
Give you a hundred and seventy it's intermittent.
Let's try a couple more.
2 6 2 6 5 6 feet and 5 inches gives you a hundred and ninety six centimetre would do one more.
Let's say 5 3 convert give you a hundred and sixty centimetre.
So we've got our height converter working properly so that's it for this lecture.
If you have any issues please to let me know.
This concludes this project.
Thanks for watching and bye for now.